import 'package:flutter/material.dart';

class GradientText extends StatelessWidget {
  final AlignmentGeometry begin;
  final AlignmentGeometry end;
  final List<Color> colors;
  final String text;
  final double fontSize;
  final FontWeight fontWeight;
  final TextAlign? textAlign;
  final int? maxLines;
  final double? height;
  final TextDecoration? decoration;
  final Color? decorationColor;

  const GradientText(
    this.text, {
    super.key,
    this.colors = const [
      Color(0xffFFE8BE),
      Color(0xffE6B764),
    ],
    this.fontSize = 14,
    this.textAlign,
    this.maxLines,
    this.height,
    this.fontWeight = FontWeight.w500,
    this.begin = Alignment.centerLeft,
    this.end = Alignment.centerRight,
    this.decoration,
    this.decorationColor,
  });

  @override
  Widget build(BuildContext context) {
    return ShaderMask(
      shaderCallback: (bounds) => LinearGradient(
        begin: begin,
        end: end,
        colors: colors,
      ).createShader(bounds),
      child: Text(
        text,
        textAlign: textAlign,
        maxLines: maxLines,
        style: TextStyle(
          fontSize: fontSize,
          fontWeight: fontWeight,
          color: Colors.white,
          height: height,
          decoration: decoration,
          decorationColor: decorationColor,
        ),
      ),
    );
  }
}
